home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tcl / dist6.3 / tests / linsert.test < prev    next >
Encoding:
Text File  |  1991-08-21  |  2.3 KB  |  66 lines

  1. # Commands covered:  linsert
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright 1991 Regents of the University of California
  8. # Permission to use, copy, modify, and distribute this
  9. # software and its documentation for any purpose and without
  10. # fee is hereby granted, provided that this copyright notice
  11. # appears in all copies.  The University of California makes no
  12. # representations about the suitability of this software for any
  13. # purpose.  It is provided "as is" without express or implied
  14. # warranty.
  15. #
  16. # $Header: /sprite/src/lib/tcl/tests/RCS/linsert.test,v 1.1 91/08/21 13:37:24 ouster Exp $ (Berkeley)
  17.  
  18. if {[string compare test [info procs test]] == 1} then {source defs}
  19.  
  20. test linsert-1.1 {linsert command} {
  21.     linsert {1 2 3 4 5} 0 a
  22. } {a 1 2 3 4 5}
  23. test linsert-1.2 {linsert command} {
  24.     linsert {1 2 3 4 5} 1 a
  25. } {1 a 2 3 4 5}
  26. test linsert-1.3 {linsert command} {
  27.     linsert {1 2 3 4 5} 2 a
  28. } {1 2 a 3 4 5}
  29. test linsert-1.4 {linsert command} {
  30.     linsert {1 2 3 4 5} 3 a
  31. } {1 2 3 a 4 5}
  32. test linsert-1.5 {linsert command} {
  33.     linsert {1 2 3 4 5} 4 a
  34. } {1 2 3 4 a 5}
  35. test linsert-1.6 {linsert command} {
  36.     linsert {1 2 3 4 5} 5 a
  37. } {1 2 3 4 5 a}
  38. test linsert-1.7 {linsert command} {
  39.     linsert {1 2 3 4 5} 2 one two \{three \$four
  40. } {1 2 one two \{three {$four} 3 4 5}
  41. test linsert-1.8 {linsert command} {
  42.     linsert {\{one \$two \{three \ four \ five} 2 a b c
  43. } {\{one \$two a b c \{three \ four \ five}
  44. test linsert-1.9 {linsert command} {
  45.     linsert {{1 2} {3 4} {5 6} {7 8}} 2 {x y} {a b}
  46. } {{1 2} {3 4} {x y} {a b} {5 6} {7 8}}
  47. test linsert-1.10 {linsert command} {
  48.     linsert {} 2 a b c
  49. } {a b c}
  50. test linsert-1.11 {linsert command} {
  51.     linsert {} 2 {}
  52. } {{}}
  53.  
  54. test linsert-2.1 {linsert errors} {
  55.     list [catch linsert msg] $msg
  56. } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  57. test linsert-2.2 {linsert errors} {
  58.     list [catch {linsert a b} msg] $msg
  59. } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  60. test linsert-2.3 {linsert errors} {
  61.     list [catch {linsert a 12x 2} msg] $msg
  62. } {1 {expected integer but got "12x"}}
  63. test linsert-2.4 {linsert errors} {
  64.     list [catch {linsert \{ 12 2} msg] $msg
  65. } {1 {unmatched open brace in list}}
  66.